<template>
  <div class="home-container">
    <section class="parallax-section">
      <transition-group 
        name="parallax" 
        tag="div" 
        class="parallax-container"
      >
        <div 
          v-for="(item, index) in parallaxItems" 
          :key="index"
          v-show="currentIndex === index"
          class="parallax-item"
        >
          <div class="parallax-image">
            <img :src="item.imageUrl" :alt="item.title">
            <div class="image-overlay"></div>
          </div>
          <div class="parallax-content">
            <div class="content-inner">
              <h1 class="main-title">艺标图映</h1>
              <p class="main-subtitle">AI驱动的艺术标印平台</p>
              <div class="content-divider"></div>
              <h2 class="sub-title">{{ item.title }}</h2>
              <p class="description">{{ item.description }}</p>
            </div>
          </div>
        </div>
      </transition-group>
    </section>

    <div class="navigation">
      <button class="nav-btn prev" @click="prevSlide">
        <span class="arrow">←</span>
      </button>
      <div class="page-numbers">
        <span 
          v-for="n in 4" 
          :key="n"
          :class="['number', { active: currentIndex === n - 1 }]"
          @click="goToSlide(n - 1)"
        >
          {{ String(n).padStart(2, '0') }}
        </span>
      </div>
      <button class="nav-btn next" @click="nextSlide">
        <span class="arrow">→</span>
      </button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const currentIndex = ref(0)

const parallaxItems = [
  {
    title: '创意设计 01',
    description: '利用AI技术，我们创造出独特的艺术作品。',
    imageUrl: 'https://picsum.photos/1200/800?random=1'
  },
  {
    title: '艺术创作 02',
    description: '突破传统界限，探索艺术与科技的完美结合。',
    imageUrl: 'https://picsum.photos/1200/800?random=2'
  },
  {
    title: '数字艺术 03',
    description: '融合数字技术与艺术创作，打造独特的视觉体验。',
    imageUrl: 'https://picsum.photos/1200/800?random=3'
  },
  {
    title: '创新设计 04',
    description: '以创新思维重新诠释艺术，创造前所未有的视觉享受。',
    imageUrl: 'https://picsum.photos/1200/800?random=4'
  }
]

const prevSlide = () => {
  currentIndex.value = (currentIndex.value - 1 + parallaxItems.length) % parallaxItems.length
}

const nextSlide = () => {
  currentIndex.value = (currentIndex.value + 1) % parallaxItems.length
}

const goToSlide = (index) => {
  currentIndex.value = index
}
</script>

<style scoped>
.home-container {
  min-height: 100vh;
  background: #000;
}

.parallax-section {
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.parallax-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.parallax-item {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.parallax-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.parallax-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.1);
  transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  filter: brightness(0.8);
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.3),
    rgba(0, 0, 0, 0.6)
  );
  z-index: 2;
}

.parallax-content {
  position: relative;
  z-index: 3;
  text-align: center;
  color: white;
  max-width: 800px;
  padding: 2rem;
}

.content-inner {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 1s forwards;
  animation-delay: 0.3s;
}

.main-title {
  font-size: 4.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
}

.main-subtitle {
  font-size: 1.8rem;
  margin-bottom: 2rem;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
  font-weight: 300;
}

.content-divider {
  width: 80px;
  height: 3px;
  background: linear-gradient(to right, transparent, #fff, transparent);
  margin: 2rem auto;
}

.sub-title {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

.description {
  font-size: 1.3rem;
  line-height: 1.8;
  max-width: 600px;
  margin: 0 auto;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

/* 导航按钮样式优化 */
.navigation {
  position: fixed;
  bottom: 3rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3rem;
  z-index: 10;
}

.nav-btn {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.3s ease;
  padding: 1rem;
}

.nav-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.page-numbers {
  display: flex;
  gap: 1.5rem;
}

.number {
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  opacity: 0.7;
  transition: all 0.3s ease;
  font-size: 1.2rem;
}

.number.active {
  opacity: 1;
  border-bottom: 2px solid white;
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 过渡效果优化 */
.parallax-enter-active,
.parallax-leave-active {
  transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.parallax-enter-from {
  transform: scale(1.2) translateX(10%);
  opacity: 0;
}

.parallax-leave-to {
  transform: scale(0.8) translateX(-10%);
  opacity: 0;
}

@media (max-width: 768px) {
  .main-title {
    font-size: 3rem;
  }
  
  .main-subtitle {
    font-size: 1.4rem;
  }
  
  .sub-title {
    font-size: 2rem;
  }
  
  .description {
    font-size: 1.1rem;
  }
}

/* 移除原有的白色背景顶栏 */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.5rem 0;
  transition: all 0.3s ease;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  height: 40px;
}

.logo img {
  height: 100%;
  width: auto;
}

.nav-menu {
  display: flex;
  gap: 2rem;
}

.nav-item {
  color: white;
  text-decoration: none;
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  position: relative;
  opacity: 0.8;
  transition: all 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
  opacity: 1;
}

.nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: white;
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.nav-item:hover::after,
.nav-item.active::after {
  width: 100%;
}

/* 滚动时的样式 */
.header-scrolled {
  background: rgba(0, 0, 0, 0.8);
  padding: 1rem 0;
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 1rem;
  }

  .nav-menu {
    gap: 1rem;
  }

  .nav-item {
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
  }
}
</style> 